class CookieUtils{

    private static index:number = 0;//选中页签

    /**
     * 保存选中页签
     */
    public static saveIndex(index:number):void{
        CookieUtils.index = index;
        CookieUtils.saveCookie();
    }

    /**
     * 保存 语言
     * @param {number} langType
     */
    public static saveLanguage(langType:number):void{
        var lastLang:number = Global.LANGUAGE;
        Global.LANGUAGE = langType;
        CookieUtils.saveCookie();
        if(Global.LANGUAGE != lastLang){
            location.reload(true);
        }
    }

    /**
     * 获取cookie选中页签
     */
    public static getIndex():number{
        return CookieUtils.getParam(0);
    }

    /**
     * 获取cookie语言
     */
    public static getLanguage():number{
        return CookieUtils.getParam(1);
    }

    //获取参数
    private static getParam(paramIndex:number):number{
        var cookie:string = document.cookie.substring(document.cookie.indexOf("game=")+5,document.cookie.indexOf("end"));
        var index:number = Number(cookie.split("_")[paramIndex]);
        index = isNaN(index) ? 0 : index;
        return index;
    }

    //保存cookie
    private static saveCookie():void{
        document.cookie = "game=" + CookieUtils.index + "_" + Global.LANGUAGE + "end";
    }
}